'use strict';

const Controller = require('egg').Controller;

class HomeController extends Controller {
  async index(ctx) {
    const data = await ctx.service.home.helloWorld();
    ctx.body = {
      code: 0,
      data,
    };
  }

  async getGithubFollowers(ctx) {
    const { user } = ctx.params;
    const { page = 1, per_page = 10 } = ctx.query;
    const data = await ctx.service.home.getGithubFollowers({
      user,
      page,
      per_page,
    });
    await ctx.render('github-followers.nj', {
      data,
      user,
    });
  }
}

module.exports = HomeController;
